/*
 * BZPView.h
 *
 *  Created on: 24/05/2014
 *      Author: javier
 */

#ifndef BZPVIEW_H_
#define BZPVIEW_H_

#include <SDL2/SDL.h>
#include <list>
#include "SDLWindow.h"
#include "Drawable.h"
#include "MenuView.h"
#include "ScenarioView.h"
#include "GameSelectView.h"
#include "DecideGameStartView.h"
#include "GeneralInfoView.h"
#include "WaitingView.h"
#include "Properties.h"

class BZPController;

enum ViewStates {
	MENU, GAME_SELECT, GAME, WAITING, DECIDE_GAME_START, MATCH_SELECT, INFO
};

/*
 * Clase que abstrae los multiples componentes de la vista al controlador
 */
class BZPView {
public:
	BZPView(SDLWindow* window, BZPModel* model);
	void setTarget(Positionable* target);
	void render();
	void update();
	void removeView(int id);
	void add(Positionable* positionable);
	void addExplosionView(Positionable* positionable);
	void handleClick(int x, int y);
	// eventos
	void newGame();
	void joinGame();
	void setScenarioDimensions(int width, int height);
	void exit();
	void changeToView(ViewStates state);
	void clear();
	void updateScore(std::string text);
	void init(BZPController* controller);
	void showCampaigns(std::string campaigns);
	void showPartidas(std::string partidas);
	void sendNewCampaign(std::string id, std::string name);
	void sendNewMatch(std::string id);
	void sendStartMatch(bool decide, std::string idPartida);
	void showInfo(InfoStates msj);

	void notifyEndGame();
	void notifyNextMatch();

	virtual ~BZPView();
private:
	std::string findAndRplace(std::string &s, std::string toReplace,
			std::string replaceWith);
	SDLWindow* window;
	MenuView menuView;
	BZPController *controller;
	ScenarioView scenarioView;
	WaitingView waitingView;
	GameSelectView gameSelectView;
	DecideGameStartView decideGameStartView;
	GeneralInfoView infoView;
	ViewStates state;
	Properties properties;
	std::string score;
};

#endif /* BZPVIEW_H_ */
